Link == true? Possible?

It is possible to prompt with a if-statement if a link in a object is existing? I mean:

for gobj_CurrentObject in gmod_CurrentModule do

{

for lnk_OutLink in gobj_CurrentObject -> "*" do

{

  if(exists(outgoingLink) == true){}

}

}

 

Is there a function among the DXL Statements which satisfies my wish?


bandchef - Fri Oct 25 08:53:42 EDT 2013

Re: Link == true? Possible?
GregM_dxler - Fri Oct 25 09:09:46 EDT 2013

Hello,

If your inside the for loop that goes through all outlinks, then you must have an outlink and you don't need the if statement.  If there is no outlinks, then the for loop is skipped.

Greg

Re: Link == true? Possible?
bandchef - Mon Oct 28 09:49:59 EDT 2013

Thank you for your answer!

I have written now this code:

 

for gobj_CurrentObject in gmod_CurrentModule do

{

for lnk_OutLink in gobj_CurrentObject -> "*" do

{

//Debug

print numLinks gobj_CurrentObject."Object Text" "\n"

gobj_CurrentObject."p_Link_Feature_existing""" == "True"

}

}

 

The thing is, that the debug statement appears in the interaction window of doors. But the line "gobj_CurrentObject."p_Link_Feature_existing""" == "True"" takes no effect. The Attribute p_Link_Feature_existing has "true" or "false" to choose. I have thought, if i make a left association the script can set the displayed value in doors...

 

 

I'm so sorry. I have Chosen the inocorrect Statement. This is the correct Statement:

gobj_CurrentObject."p_Link_Feature_existing" = "True"

Re: Link == true? Possible?
pommCannelle - Mon Oct 28 10:39:58 EDT 2013

bandchef - Mon Oct 28 09:49:59 EDT 2013

Thank you for your answer!

I have written now this code:

 

for gobj_CurrentObject in gmod_CurrentModule do

{

for lnk_OutLink in gobj_CurrentObject -> "*" do

{

//Debug

print numLinks gobj_CurrentObject."Object Text" "\n"

gobj_CurrentObject."p_Link_Feature_existing""" == "True"

}

}

 

The thing is, that the debug statement appears in the interaction window of doors. But the line "gobj_CurrentObject."p_Link_Feature_existing""" == "True"" takes no effect. The Attribute p_Link_Feature_existing has "true" or "false" to choose. I have thought, if i make a left association the script can set the displayed value in doors...

 

 

I'm so sorry. I have Chosen the inocorrect Statement. This is the correct Statement:

gobj_CurrentObject."p_Link_Feature_existing" = "True"

( Hmmm ... You should try something like this ...

bool hasInLink( Object o, string linkModName ) {
    Link l
    for l in o<-linkModName do return true
    return false
}
bool hasInLink( Object o ) { return hasInLink( o, "*" ) }
bool hasOutLink( Object o, string linkModName ) {
    Link l
    for l in o->linkModName do return true
    return false
}
bool hasOutLink( Object o ) { return hasOutLink( o, "*" ) }
bool hasLink ( Object o ) { return ( (hasOutLink o) || (hasInLink o) ) }
Object o

for o in current Module do { o."p_link_feature_existing" = hasLink o }

Feel free to post your code if you are in trouble ;) )

Re: Link == true? Possible?
GregM_dxler - Mon Oct 28 12:00:56 EDT 2013

bandchef - Mon Oct 28 09:49:59 EDT 2013

Thank you for your answer!

I have written now this code:

 

for gobj_CurrentObject in gmod_CurrentModule do

{

for lnk_OutLink in gobj_CurrentObject -> "*" do

{

//Debug

print numLinks gobj_CurrentObject."Object Text" "\n"

gobj_CurrentObject."p_Link_Feature_existing""" == "True"

}

}

 

The thing is, that the debug statement appears in the interaction window of doors. But the line "gobj_CurrentObject."p_Link_Feature_existing""" == "True"" takes no effect. The Attribute p_Link_Feature_existing has "true" or "false" to choose. I have thought, if i make a left association the script can set the displayed value in doors...

 

 

I'm so sorry. I have Chosen the inocorrect Statement. This is the correct Statement:

gobj_CurrentObject."p_Link_Feature_existing" = "True"

Hello,

If the attribute p_Link_Feature_existing is a boolean, then your assignment statement should not have "True" but just true without the double quotes.  The double quotes would be used if the attribute is a string.

This error has nothing to do with the loop.

Greg

Re: Link == true? Possible?
llandale - Mon Oct 28 14:51:19 EDT 2013

bandchef - Mon Oct 28 09:49:59 EDT 2013

Thank you for your answer!

I have written now this code:

 

for gobj_CurrentObject in gmod_CurrentModule do

{

for lnk_OutLink in gobj_CurrentObject -> "*" do

{

//Debug

print numLinks gobj_CurrentObject."Object Text" "\n"

gobj_CurrentObject."p_Link_Feature_existing""" == "True"

}

}

 

The thing is, that the debug statement appears in the interaction window of doors. But the line "gobj_CurrentObject."p_Link_Feature_existing""" == "True"" takes no effect. The Attribute p_Link_Feature_existing has "true" or "false" to choose. I have thought, if i make a left association the script can set the displayed value in doors...

 

 

I'm so sorry. I have Chosen the inocorrect Statement. This is the correct Statement:

gobj_CurrentObject."p_Link_Feature_existing" = "True"

  • gobj_CurrentObject."p_Link_Feature_existing""" == "True"

With "==" that is not an assignment statement, it is a comparison.  It calculates to either true or false but does nothing besides that, and for some reason DXL doesn't complain.  That like talking to somebody and saying "The Car".  Use a single equal sign for assignment; get rid of double double quotes.  If the attr is really a boolean, do this:

  • gobj_CurrentObject."p_Link_Feature_existing" = true

Actually I think what you want is the following.  Lets create a boolean Attr-DXL that is "true" if the object has an outlink otherwise "false".  This way the attr always has the correct information and you don't need to run an on-demand script to update the values.

  • bool HasLink = false
  • Link lnk
  • for lnk in obj-> "*" do
  • { 
         // if (I don't care about THIS link) then continue
    //Debug
  •      print "Has Link\t" identifier(obj) "\n"
         HasLink =  true
  •      break    // no reason to keep looking
  • }
  • obj.attrDXLName = HasLink

Merge in pommCannelle's good clean advise: do well defiined chores in well defined functions.

Now if your target attr is not "boolean" but is enumerated with "true" and "false" or "True" and "False" then your assignment would be a string. 

-Louie

Digressing:  If "False" is the first enumeration and "True" is second, turns out the boolean assignment will still work.

Re: Link == true? Possible?
GregM_dxler - Mon Oct 28 16:24:53 EDT 2013

llandale - Mon Oct 28 14:51:19 EDT 2013

  • gobj_CurrentObject."p_Link_Feature_existing""" == "True"

With "==" that is not an assignment statement, it is a comparison.  It calculates to either true or false but does nothing besides that, and for some reason DXL doesn't complain.  That like talking to somebody and saying "The Car".  Use a single equal sign for assignment; get rid of double double quotes.  If the attr is really a boolean, do this:

  • gobj_CurrentObject."p_Link_Feature_existing" = true

Actually I think what you want is the following.  Lets create a boolean Attr-DXL that is "true" if the object has an outlink otherwise "false".  This way the attr always has the correct information and you don't need to run an on-demand script to update the values.

  • bool HasLink = false
  • Link lnk
  • for lnk in obj-> "*" do
  • { 
         // if (I don't care about THIS link) then continue
    //Debug
  •      print "Has Link\t" identifier(obj) "\n"
         HasLink =  true
  •      break    // no reason to keep looking
  • }
  • obj.attrDXLName = HasLink

Merge in pommCannelle's good clean advise: do well defiined chores in well defined functions.

Now if your target attr is not "boolean" but is enumerated with "true" and "false" or "True" and "False" then your assignment would be a string. 

-Louie

Digressing:  If "False" is the first enumeration and "True" is second, turns out the boolean assignment will still work.

Owwww, my eyes can't see the fine print!

Re: Link == true? Possible?
llandale - Tue Oct 29 14:20:16 EDT 2013

GregM_dxler - Mon Oct 28 16:24:53 EDT 2013

Owwww, my eyes can't see the fine print!

Don't know what I did wrong; cannot preview.  Any ideas?

Re: Link == true? Possible?
GregM_dxler - Tue Oct 29 14:38:30 EDT 2013

llandale - Tue Oct 29 14:20:16 EDT 2013

Don't know what I did wrong; cannot preview.  Any ideas?

Must be a forum "enhancement".

bandchef had already acknowledged that the "==" should have been an assignment "=" in his (?) fine print.  The text below the square bullets is too small to read.  Not sure if that was because you copied his text to your reply, the font size got even smaller then what he had (which is way too small).  It seems to be below the resolution of my monitor now.

Greg